package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.MonthPerformance;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IMonthPerformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实施情况月报Controller
 * 
 * @author ruoyi
 * @date 2022-04-18
 */
@RestController
@RequestMapping("/system/performance")
public class MonthPerformanceController extends BaseController
{
    @Autowired
    private IMonthPerformanceService monthPerformanceService;

    /**
     * 查询实施情况月报列表
     */
    @PreAuthorize("@ss.hasPermi('system:performance:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonthPerformance monthPerformance)
    {
        startPage();
        List<MonthPerformance> list = monthPerformanceService.selectMonthPerformanceList(monthPerformance);
        return getDataTable(list);
    }

    /**
     * 导出实施情况月报列表
     */
    @PreAuthorize("@ss.hasPermi('system:performance:export')")
    @Log(title = "实施情况月报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MonthPerformance monthPerformance)
    {
        List<MonthPerformance> list = monthPerformanceService.selectMonthPerformanceList(monthPerformance);
        ExcelUtil<MonthPerformance> util = new ExcelUtil<MonthPerformance>(MonthPerformance.class);
        return util.exportExcel(list, "实施情况月报数据");
    }

    /**
     * 获取实施情况月报详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:performance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(monthPerformanceService.selectMonthPerformanceById(id));
    }

    /**
     * 新增实施情况月报
     */
    @PreAuthorize("@ss.hasPermi('system:performance:add')")
    @Log(title = "实施情况月报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonthPerformance monthPerformance)
    {
        return toAjax(monthPerformanceService.insertMonthPerformance(monthPerformance));
    }

    /**
     * 修改实施情况月报
     */
    @PreAuthorize("@ss.hasPermi('system:performance:edit')")
    @Log(title = "实施情况月报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonthPerformance monthPerformance)
    {
        return toAjax(monthPerformanceService.updateMonthPerformance(monthPerformance));
    }

    /**
     * 删除实施情况月报
     */
    @PreAuthorize("@ss.hasPermi('system:performance:remove')")
    @Log(title = "实施情况月报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(monthPerformanceService.deleteMonthPerformanceByIds(ids));
    }
}
